/*
 * vertex.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef VERTEX_H_
#define VERTEX_H_



#include <string>
#include <vector>

class Triangle;
class Edge;
using namespace std;


class Vertex
{
private:
    double x, y, z;
    int index;
    bool fixed;
    vector<Triangle*> trianglesContainingVertex;
    vector<Edge*> edgesConnectingVertex;
    vector<Edge*> edgesOppositeToVertex;

public:
    Vertex ( double X, double Y, double Z ) : x ( X ),y ( Y ),z ( Z ) {fixed = false;};
    Vertex() {x=0; y=0; z=0;};
    ~Vertex() {};


    string toString();
    string toVTKString();


    vector<Triangle*>* getTrianglesContainingVertex() {
        return &trianglesContainingVertex;
    }
    vector<Edge*>* getEdgesConnectingVertex() {
        return &edgesConnectingVertex;
    }
    vector<Edge*>* getEdgesOppositeToVertex() {
        return &edgesOppositeToVertex;
    }


    bool operator== ( Vertex const& v ) const;
    bool operator!= ( Vertex const& v ) const;
    Vertex operator- ( Vertex v ) ;
    Vertex operator+ ( Vertex v ) ;
    void operator+= ( Vertex v ) ;
    void operator-= ( Vertex v ) ;
    double operator* ( Vertex & v ) ;
    Vertex operator* ( double c ) ;
    Vertex operator/ ( double c ) ;

    Vertex cross ( Vertex v) ;
    double abs();

    int getIndex(){ return index; };
    void setIndex(int i) {index=i;};

    double getX() {return x; };
    double getY(){return y; };
    double getZ(){return z; };

    void setX(double X){ x=X; };
    void setY(double Y){ y=Y; };
    void setZ(double Z){ z=Z; };
    void setCoordinates(double X, double Y, double Z);

    void setFixed(bool FIXED){ fixed = FIXED; };
    bool isFixed(){return fixed;};

    double getAssociatedArea();

    void moveBy(Vertex & v);
    int getEdgePosOfConnectingEdges(Edge * e);
    int getEdgePosOfOppositeEdges(Edge * e);
    int getTrianglePos(Triangle * t);

    bool isEndpointOfSF(int fibernumber);
    void removeAssociatedEdge(Edge * e);
};

#endif /* VERTEX_H_ */
